<?php

namespace app\admin\service;

use app\admin\dao\ConsultingSubsidyDao;
use app\admin\model\UM as UM;
use ShidianUtil\Utils\TimeUtil;
use think\Collection;

/**
 * Class SubsidyService
 * @package app\admin\service
 */
class SubsidyService
{
    // dao
    private ConsultingSubsidyDao $consultingSubsidyDao;

    public function __construct(ConsultingSubsidyDao $consultingSubsidyDao)
    {
        $this->consultingSubsidyDao = $consultingSubsidyDao;
    }

    /**
     * 补贴列表
     * @param UM|null $user
     * @param $provinceId
     * @param $cityId
     * @param $categoryId
     * @param $serverId
     * @param $startTime
     * @param $endTime
     * @param $kw
     * @param int|null $page
     * @param int|null $page_size
     * @return array
     */
    public function index(?UM $user, $provinceId, $cityId, $categoryId, $serverId, $startTime, $endTime, $kw, ?int $page = null, ?int $page_size = null): array
    {
        if(is_numeric($endTime)){
            $endTime = TimeUtil::stamp(TimeUtil::DAY, $endTime, false);
        }
        return $this->consultingSubsidyDao->listSubsidies($provinceId, $cityId, $categoryId, $serverId, $startTime, $endTime, $kw, $page, $page_size);
    }


}
